package org.standard.commons.tlds;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class TagServerDate extends TagSupport {
	
	private static final long serialVersionUID = -3166812535628021005L;

	private String format = null;//

	@Override
	public int doEndTag() throws JspException {

		return EVAL_PAGE;
	}

	@Override
	public int doStartTag() throws JspException {
		
		try {
			JspWriter out = pageContext.getOut();
	        out.print(new SimpleDateFormat(format).format(new Date()));
	    } catch (Exception e){
	        e.printStackTrace();
	    }
	    return EVAL_BODY_INCLUDE;

	}

	public void setFormat(String format) {
		this.format = format;
	}

}
